|
|
|
|
|
|
|
This code first calls the EmployeeDisplay() function, and the return value goes into the strName variable. The MsgBox procedure is then called and passed this string variable. Of course, I could have just put the EmployeeDisplay() function immediately after the MsgBox procedure because its expecting a string variable, which is exactly whats returned from the EmployeeDisplay() function. A function can be called just like a procedure, as shown here: |
|
|
|
 |
|
|
|
|
Call EmployeeDisplay() |
|
|
|
|
|
|
|
|
In this case, the return value from the EmployeeDisplay() function is simply thrown away. You may be wondering why you would do this? Why not just make this function a procedure? What will be the deciding factor on whether you create a function or a procedure is whether you need to retrieve a value back from the routine. |
|
|
|
|
|
|
|
|
If you look at the MsgBox procedure thats called to display information in a dialog box on the screen, youll notice that you always have to give it some string input. This input is called a parameter. A parameter is something you pass to a procedure so that it can do something with that value. The MsgBox procedure takes the parameter thats passed and displays it in a dialog box on the screen. You can pass parameters to your own procedures as long as you set up the arguments to accept them. |
|
|
|
|
|
|
|
|
Examples Filename: Employee.frm |
|
|
|
 |
|
|
|
|
NOTE When you pass a value to a procedure, its called a parameter. In the declaration of that procedure, the values coming in are called arguments. |
|
|
|
|
|
|
|
|
Defining Arguments in Your Procedures |
|
|
|
|
|
|
|
|
Procedures and function can accept any type of argument you want. You just need to give the argument a name and a data type, just like you would a local variable. In fact, arguments are just local variables that happen to be declared on the same line as the procedure name. To create a procedure that accepts arguments, you would write the procedure definition as follows: |
|
|
|
 |
|
|
|
|
Public Sub EmployeeDisplay(strFirst As String, _
strLast As String) |
|
|
|
|
|